const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
export default {
  namespace: "count",
  state: {
    num: 0,
  },
  reducers: {
    add(state: any, action: { num: number }) {
      state.num += action.num;
      return { ...state };
    },
  },
  effects: {
    *addAsync(_action: any, { put }: any) {
      yield delay(1000);
      yield put({ type: "add" });
    },
  },
};
